home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 11 / CU Amiga Magazine's Super CD-ROM 11 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-06].iso / s / dropcaps.pprx < prev    next >
Text File  |  1992-03-14  |  4KB  |  156 lines

  1. /*
  2. @BDropCaps  @P@ICopyright Gold Disk Inc., February, 1992
  3.  
  4. This Genie creates a drop cap by extracting a number of characters from the first paragraph of a box and placing them in a new box.
  5. */
  6. if ~show(l, "gdarexxsupport.library") then
  7.         if ~addlib("gdarexxsupport.library", 0, -30) then
  8.                 exit_msg("Please install the gdarexxsupport.library in your libs: directory before running this Genie.")
  9.  
  10. cr = '0a'x
  11. call SafeEndEdit.rexx()
  12. units = ppm_GetUnits()
  13. call ppm_SetUnits(1)
  14. address command
  15. signal on halt
  16. signal on break_c
  17. signal on break_e
  18. signal on break_d
  19.  
  20. box   = ppm_ClickOnbox("Click on box in which to add drop cap..")
  21.  
  22. if box = 0 then exit_msg()
  23.  
  24. if upper(word(ppm_GetBoxInfo(box), 1)) ~= 'TEXT' then
  25.    exit_msg("The box must contain text..")
  26.  
  27. form  = ppm_GetForm("Enter drop cap info", 8, "# letters:1"cr"# lines:3")
  28. if form = '' then exit_msg()
  29.  
  30. call ppm_AutoUpdate(0)
  31.  
  32. parse var form letters '0a'x lines
  33.  
  34. if datatype(letters) ~= 'NUM' | datatype(lines) ~= 'NUM' then
  35.    exit_msg("Invalid input")
  36.  
  37. text  = ppm_GetArticleText(box, 1)
  38. if text = '' then exit_msg("No text in box")
  39.  
  40. droptext = ''
  41. letter = 0
  42. cpos = 1
  43.  
  44. do while letter < letters
  45.  
  46.     cpos = skipcodes(text, cpos)
  47.     if cpos = 0 then leave
  48.     char = substr(text, skipcodes(text, cpos), 1)
  49.  
  50.     if char = "\" then iterate
  51.  
  52.     droptext = droptext || char
  53.     text = delstr(text, cpos, 1)
  54.     letter = letter + 1
  55.  
  56. end
  57.  
  58. angle = ppm_GetBoxAngle(box)
  59. marg  = ppm_GetBoxMargins(box)
  60. bpos  = ppm_GetBoxPosition(box)
  61.  
  62. call ppm_ShowStatus("Working..")
  63. call SafeSetEdit.rexx(box)
  64.  
  65. size  = ppm_GetSize()
  66. font  = ppm_GetFont()
  67. color = ppm_GetTextColor()
  68. lspce = ppm_GetLineSpacing()
  69. call SafeEndEdit.rexx()
  70.  
  71. type = word(lspce, 1)
  72.  
  73. if type = 0 then
  74.     lspce = size + word(lspce, 2)
  75. else if type = 1 then
  76.     lspce = word(lspce, 2)
  77. else
  78.     lspce = size * (word(lspce,2)/100)
  79.  
  80. font   = ppm_SelectFromList("Select Drop Cap font", 30, 8, 0, FontList.rexx(font))
  81. if font = '' then exit_msg()
  82.  
  83. boxheight   = (word(marg, 2) + max(1, lines) * lspce + word(marg, 4)) / 72
  84. boxwidth    = (word(marg, 1) + .7 * lines * size * letters + word(marg, 3)) / 72
  85.  
  86. newbox   = ppm_CreateBox(-1000, -1000, boxwidth, boxheight, angle)
  87.  
  88. call ppm_SetBoxTextWrap(newbox,1, 2)
  89. call ppm_SetBoxStandoff(newbox, .1)
  90. call ppm_BoxToFront(newbox)
  91.  
  92. call SafeSetEdit.rexx(newbox)
  93. call ppm_SetSize(max(1, lines) * lspce)
  94. call ppm_SetFont(font)
  95. call ppm_SetTextColor(color)
  96. call ppm_SetLineSpacing(2, 100)
  97. call SafeEndEdit.rexx()
  98. call ppm_TextIntoBox(newbox, droptext)
  99. call ppm_DeleteContents(box)
  100. call ppm_TextIntoBox(box, text)
  101. call ppm_ShowStatus("Reflowing text..")
  102.  
  103. if ppm_TextOverFlow(newbox) then 
  104. do
  105.  
  106.     call ppm_SetBoxTextWrap(newbox,1, 2)
  107.  
  108.     oldboxheight = boxheight
  109.     oldboxwidth  = boxwidth
  110.  
  111.     boxheight   = 1.2 * boxheight
  112.     call ppm_SetBoxSize(newbox, boxwidth, boxheight)
  113.     call ppm_ShowStatus("Working..")
  114.  
  115.     /*  working on text box */
  116.     do while ppm_TextOverFlow(newbox)
  117.  
  118.         boxwidth  = 1.1 * boxwidth
  119.         call ppm_SetBoxSize(newbox, boxwidth, boxheight)
  120.  
  121.     end
  122.  
  123.     tempbox = ppm_CreateBox(word(bpos, 1), word(bpos, 2), boxwidth, lspce / 72 * (lines - .5) + word(marg, 2) + word(marg, 4), angle)
  124.     call ppm_BoxToFront(tempbox)
  125.     call ppm_BoxToFront(newbox)
  126.     call ppm_SetBoxTextWrap(tempbox,word(1,1), word(1,2))
  127.     call ppm_SetBoxTextWrap(newbox,word(0,1), word(0,2))
  128. end
  129.  
  130. call ppm_SetBoxPosition(newbox, word(bpos, 1), word(bpos, 2))
  131.  
  132. exit_msg("Done")
  133.  
  134. halt:
  135. break_c:
  136. break_e:
  137. break_d:
  138.    call exit_msg("User Aborted Genie")
  139.  
  140. exit_msg: procedure expose units
  141. do
  142.  
  143.    parse arg message
  144.  
  145.    call ppm_SetUnits(units)
  146.  
  147.    if message ~= '' then
  148.       call ppm_Inform(1, message,)
  149.  
  150.    call ppm_ClearStatus()
  151.    call ppm_AutoUpdate(1)
  152.    exit
  153. end
  154.  
  155.